﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DTO_QLNS;
using ADO_QLNS;
using System.Collections;

namespace BUS_QLNS
{
    public class BookBUS : IBUS
    {
        private BookDTO _DTO;
        private BookADO _ADO = new BookADO();

        public BookDTO GetBook(int bookID)
        {
            _DTO = new BookDTO();
            _DTO.BookID = bookID;
            return _ADO.GetBook(_DTO);
        }

        public List<BookDTO> GetBookByAuthor(int authorID)
        {
            List<BookDTO> ls = new List<BookDTO>();
            ArrayList arr = _ADO.GetBookByAuthor(authorID);
            for (int i = 0; i < arr.Count; ++i)
                ls.Add((BookDTO)arr[i]);

            return ls;
        }

        public List<BookDTO> GetBookByCategory(int categoryID)
        {
            List<BookDTO> ls = new List<BookDTO>();
            ArrayList arr = _ADO.GetBookByCategory(categoryID);
            for (int i = 0; i < arr.Count; ++i)
                ls.Add((BookDTO)arr[i]);

            return ls;
        }

        public List<BookDTO> GetBookByAuthorAndCategory(string bookName, int catID, int autID)
        {
            List<BookDTO> ls = new List<BookDTO>();
            ArrayList arr = _ADO.SearchByAuthorAndCategory(bookName, catID, autID);
            for (int i = 0; i < arr.Count; ++i)
                ls.Add((BookDTO)arr[i]);

            return ls;
        }
    }
}
